package com.hp.docker_base.service.impl;

import com.hp.docker_base.bean.Department;

import com.hp.docker_base.mapper.DepartmentMapper;
import com.hp.docker_base.service.IDepartmentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * @Desc TODO
 * @Author 24763
 * @Date 2020/7/6 16:59
 */
@Service
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;


    @Override
    public List<Department> queryDepartmentList(List<String> departmentIdList) {
        if(!CollectionUtils.isEmpty(departmentIdList)){
            return departmentMapper.findDepartmentListByIdList(departmentIdList);
        }
        return null;
    }

    @Override
    public List<Department> queryAllDepartmentList(String keywords) {
        return departmentMapper.selectAllDepartmentList(keywords);
    }



    @Override
    public int findDefaultSort() {
        List<Department> departmentList = departmentMapper.selectAllDepartmentList(null);
        if(!CollectionUtils.isEmpty(departmentList)){
            return departmentList.size()+1;
        }
        return 0;
    }





    @Override
    public Department queryDepartmentByUUID(String departmentId) {
        if(!StringUtils.isEmpty(departmentId)){
            return departmentMapper.selectDepartmentByUUID(departmentId);
        }
        return null;
    }

    public Department findDepartmentByUUID(String departmentId){
        if(StringUtils.isEmpty(departmentId)){
            return null;
        }

        return departmentMapper.selectDepartmentByUUID(departmentId);
    }

}
